package com.briansteen.sketches;

import java.util.List;

import cc.creativecomputing.graphics.CCGraphics;
import cc.creativecomputing.graphics.font.CCFontIO;
import cc.creativecomputing.math.CCMath;
import cc.creativecomputing.math.CCVector3f;

import com.briansteen.painterface.BasicColor;

public class TweetingPainterFaceEntry {

	private BasicColor color;
	private List<CCVector3f> text;
	private int step = 0;
	private boolean done = false;
	private float width, height;
	
	private float rotation = 0;
	private boolean rotate = true;
	
	public TweetingPainterFaceEntry(String message, float width, float height) {
		text = CCFontIO.createOutlineFont("LucidaHandwriting-Italic", 10, 10).getPath(message, CCGraphics.ALIGN_CENTER, 50, CCMath.random(-(width/2), (width/2)), CCMath.random(-(height/2), (height/2)), 0);
		
		color = new BasicColor(0, 0);
		color.red = 0;
		color.green = 0;
		color.blue = 0;
		
		this.width = width;
		this.height = height;
		
		this.rotation = CCMath.degreesToRadians(CCMath.random(360));
	}
	
	public void draw(CCGraphics g) {
		if(step < text.size()) {
			float x = text.get(step).x();
			float y = text.get(step).y();
			if(x > -(width/2) && x < (width/2) && y > -(height/2) && y < (height/2)) {
				color.blue = (float)Math.sin(System.currentTimeMillis() * .001)*.25f + .3f;
				color.draw(g, x, y);
				color.drawParticles(g);
			}
			
			step++;
		} if(step == text.size()) this.done = true;
	}
	
	public boolean isDone() { return done; }
	
}
